<?php

declare(strict_types=1);

namespace App\Library\Task\library\queue\drivers\redis;

use App\Library\Task\library\queue\drivers\DriverClientImp;
use Hyperf\Utils\ApplicationContext;

class QueueClientRedis implements DriverClientImp
{
    /**
     * 入列
     * @param string $key
     * @param array $value
     */
    public function push($key, $value, $queueDriver = 'default') {
        return ApplicationContext::getContainer()->get(QueueDBRedis::class)->push(serialize(array($key => $value)), $queueDriver);
    }

    /**
     * 出列
     * @param string $key
     * @param array $value
     */
    public function pop($key, $queueDriver='default') {
        return unserialize(ApplicationContext::getContainer()->get(QueueDBRedis::class)->pop($key, $queueDriver));
    }

    /**
     *
     * @param string $key
     * @param array $value
     */
    public function scan($queueDriver = 'default') {
        return ApplicationContext::getContainer()->get(QueueDBRedis::class)->scan($queueDriver);
    }

}